//
//  DecorateHeaderTableViewCell.m
//  PerfectWorld
//
//  Created by dllo on 16/8/27.
//  Copyright © 2016年 LST. All rights reserved.
//  主VC自定义Cell

#import "DecorateHeaderTableViewCell.h"
#import "Projects.h"
#import "User.h"
#import "UserImage.h"
#import "UIImageView+WebCache.h"
#import "HeadImage.h"
@implementation DecorateHeaderTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatSubView:self.bounds];
    }
    return self;
}
- (void)setProjectModel:(Projects *)projectModel {
    _projectModel = projectModel;
    _labelTitle.text = projectModel.title;
    _labelPrice.text = [NSString stringWithFormat:@"%@.%@.%@平米.%@万元",projectModel.styleShow, projectModel.typeShow, projectModel.areaShow, projectModel.costShow];
    _leftLabel.text = projectModel.buildingName;
    [_titleImage sd_setImageWithURL:[NSURL URLWithString:projectModel.user.userImage.medium] placeholderImage:nil];
    NSNumber *num = @(projectModel.coverPhoto);
    NSString *str = [num description];
    NSString *str1 = [str substringToIndex:3];
    [_decorateImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://image.gooju.cn/images/%@/9/%@_0_9-.jpg", str1, str]] placeholderImage:nil];
    
}
- (void)creatSubView:(CGRect)sender {
    _decorateImage = [[UIImageView alloc] initWithFrame:CGRectZero];
    [self.contentView addSubview:_decorateImage];
    _leftLabel = [[UILabel alloc] initWithFrame:CGRectZero];
    _leftLabel.textColor = [UIColor whiteColor];
    _leftLabel.backgroundColor = [UIColor colorWithRed:0.17 green:0.08 blue:0.05 alpha:1.00];
    _leftLabel.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:_leftLabel];
    _labelTitle = [[UILabel alloc] initWithFrame:CGRectZero];
    _labelTitle.textColor = [UIColor colorWithRed:0.40 green:0.40 blue:0.40 alpha:1.00];
    _labelTitle.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:_labelTitle];
    _labelPrice = [[UILabel alloc] initWithFrame:CGRectZero];
    _labelPrice.textColor = [UIColor colorWithRed:0.54 green:0.54 blue:0.54 alpha:1.00];
    _labelPrice.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:_labelPrice];
    _titleImage = [[HeadImage alloc] initWithFrame:CGRectZero];
    [_decorateImage addSubview:_titleImage];
}
- (void)layoutSubviews {
    [super layoutSubviews];
    _decorateImage.frame = CGRectMake(0, 10, self.bounds.size.width, self.bounds.size.height * 0.8);
    _leftLabel.frame = CGRectMake(20, 20, 80, 30);
    _labelTitle.frame = CGRectMake(20, self.bounds.size.height * 0.75 , self.bounds.size.width, self.bounds.size.height * 0.1);
    _labelPrice.frame = CGRectMake(20, self.bounds.size.height * 0.9 , self.bounds.size.width, self.bounds.size.height * 0.05);
    _titleImage.frame = CGRectMake(self.bounds.size.width * 0.75, self.bounds.size.height * 0.45, 70, 70 );
}

@end
